import { _decorator, Component, Node } from 'cc';
import { GGResource } from '../../../framework/core/base/GGResource';
import { Material } from 'cc';
import { MeshRenderer } from 'cc';
import Config from '../../../utils/Config';
import { EventTouch } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Brick')
export class Brick extends Component {
    // 颜色
    private _color: number = -1

    // 定位
    public _x: number = -1
    public _z: number = -1

    // 是否初始化的数量
    public isBase = false
    
    // ------------------ 外部调用 ------------------ //
    public setLoc(x: number, z: number) {
        this.x = x
        this.z = z
    }

    // ------------------ Set Get ------------------ //
    public set color(value: number) {
        this._color = value
        const self = this
        
        GGResource.load("game:res/materials/六边形/" + Config.padZero((value + 1), 2), Material).then((ma: Material) => {
            const meshRender = self.node.getChildByName("消消四边形").getChildByName("柱体").getComponent(MeshRenderer)
            meshRender.material = ma
        });
    }

    public get color(): number {
        return this._color
    }

    public set x(value: number) {
        this._x = value
    }

    public get x(): number {
        return this._x
    }

    public set z(value: number) {
        this._z = value
    }

    public get z(): number {
        return this._z
    }
}


